package com.base.utils;

import java.util.Random;

public class CardUtils {
	public int CardNum() {
		Random ran = new Random();
		return ran.nextInt(999);
	}

	public int Password() {
		Random ran = new Random();
		int a = getRandom(100, 999);
		int b = ran.nextInt(1111 * 9999);
		int pwd = a + b;
		return pwd;
	}

	/*
	 * 原理:要得到的随机数的范围是[2,100]，假设返回的伪随机数的范围是[0,N)，也即[0,N-1];对得到的这个数模99，
	 * 于是计算得到的数的范围是[0,98]；再把结果加2，范围就是[2,100]了。
	 */
	public static int getRandom(int min, int max) {
		Random random = new Random();
		int s = random.nextInt(max) % (max - min + 1) + min;
		return s;
	}

//	public static String getCardInno(int i){
//
//	}

	public static String addZeroForNum(String str,int strLength) {
		int strLen =str.length();
		if (strLen <strLength) {
			while (strLen< strLength) {
				StringBuffer sb = new StringBuffer();
				sb.append("0").append(str);//左补0
//    sb.append(str).append("0");//右补0
				str= sb.toString();
				strLen= str.length();
			}
		}

		return str;
	}

}
